<%@ include file="init.jsp" %>

<portlet:renderURL var='urlAddList'><portlet:param name='action' value='addList'/><portlet:param name='order' value='${order}'/><portlet:param name='listaZakupowId' value='${listaZakupowId}'/></portlet:renderURL>
<portlet:renderURL var='urlEditList'><portlet:param name='action' value='addList'/><portlet:param name='order' value='${order}'/><portlet:param name='listaZakupowId' value='${listaZakupowId}'/></portlet:renderURL>
<portlet:renderURL var='urlAddItem'><portlet:param name='action' value='addItem'/><portlet:param name='order' value='${order}'/><portlet:param name='listaZakupowId' value='${listaZakupowId}'/></portlet:renderURL>
<portlet:renderURL var='urlViewGrupyTowarow'><portlet:param name='action' value='viewGrupyTowarow'/></portlet:renderURL>
<portlet:renderURL var='def'><portlet:param name='action' value='view'/></portlet:renderURL>

<p>
	<aui:button name='addList' value='add-list' onclick='<%=renderResponse.getNamespace()+"toAddList()" %>' />
	<c:if test="${listaZakupowId!=null}">
		<aui:button name='addItem' value='add-item' onclick='<%=renderResponse.getNamespace()+"toAddItem()" %>' />
	</c:if>
	<c:if test="${listaZakupowId!=null}">
		<aui:button name='editItem' value='edit-item' onclick='<%=renderResponse.getNamespace()+"toAddList()" %>' />
	</c:if>
	<aui:button name='viewGrupyTowarow' value='viewGrupyTowarow' onclick='<%=renderResponse.getNamespace()+"toGrupyTowarow()" %>' />
</p>

<liferay-ui:tabs
	names="${formNames}"
	value="${formTab}"
	url='<%=def %>'
	refresh="<%= true %>"
	/>


	<div style="float: left; margin-right: 4px; height: 43px;" >
		<aui:field-wrapper label="id" >
			'${order}'
		</aui:field-wrapper>
	</div>

		<c:if test="${listaZakupowId!=null}">
			<liferay-ui:icon
				cssClass="top-link"
				image="edit"
				label="<%= true %>"
				message="lists.editlist" 
				url='${urlEditList}'
				/>
		</c:if>




<aui:script>
	function <%=renderResponse.getNamespace() %>toAddList() {
		window.location.href='<%=urlAddList %>';
		}

	function <%=renderResponse.getNamespace() %>toAddItem() {
		window.location.href='<%=urlAddItem %>';
		}
		
	function <%=renderResponse.getNamespace() %>toGrupyTowarow() {
		window.location.href='<%=urlViewGrupyTowarow %>';
		}
</aui:script>

<table style='width: 100%;'>
	<tr class="portlet-section-header results-header">
		<td>
			<b>
				<a style='text-decoration: none;' href='<portlet:renderURL>
						<portlet:param name='action' value='view'/>
						<portlet:param name='listaZakupowId' value='${listaZakupowId}'/>
						<portlet:param name='order' value='kolejnosc'/>
						</portlet:renderURL>'>

					<liferay-ui:message key="kolejnosc" />

					<c:if test="${order=='label'}">
						&or;
					</c:if>
				</a>
			</b>
		</td>
		<td>
			<b>
				<a style='text-decoration: none;' href='<portlet:renderURL>
						<portlet:param name='action' value='view'/>
						<portlet:param name='listaZakupowId' value='${listaZakupowId}'/>
						<portlet:param name='order' value='nazwa'/>
						</portlet:renderURL>'>

					<liferay-ui:message key="nazwa" />

					<c:if test="${order=='nazwa'}">
						&or;
					</c:if>
				</a>
			</b>
		</td>
		<td>
			<b>
				<a style='text-decoration: none;' href='<portlet:renderURL>
						<portlet:param name='action' value='view'/>
						<portlet:param name='listaZakupowId' value='${listaZakupowId}'/>
						<portlet:param name='order' value='ilosc'/>
						</portlet:renderURL>'>

					<liferay-ui:message key="ilosc" />

					<c:if test="${order=='ilosc'}">
						&or;
					</c:if>
				</a>
			</b>
		</td>
		<td>
			<b>
				<a style='text-decoration: none;' href='<portlet:renderURL>
						<portlet:param name='action' value='view'/>
						<portlet:param name='listaZakupowId' value='${listaZakupowId}'/>
						<portlet:param name='order' value='jednostka'/>
						</portlet:renderURL>'>

					<liferay-ui:message key="jdenostka" />

					<c:if test="${order=='jednostka'}">
						&or;
					</c:if>
				</a>
			</b>
		</td>
	</tr>

	<c:forEach var="item" items="${itemList}">
		<portlet:renderURL var='urlViewItem'>
			<portlet:param name='listaZakupowId' value='${listaZakupowId}'/>
			<portlet:param name='itemid' value='${item.id}'/>
		</portlet:renderURL>

		<tr>
			<td>
				<span style='color: #7B7C7F'>${item.kolejnosc}</span>
			</td>
			<td>		
				<aui:a href='${urlViewItem}'>
					${item.nazwa}
				</aui:a>
			</td>
			<td>
				<span style='color: #7B7C7F'>${item.ilosc}</span>
			</td>
			<td>
				<span style='color: #7B7C7F'>${item.jednostka}</span>
			</td>
		</tr>
	</c:forEach>
</table>